import Vue from 'vue'
import App from './App.vue'
import router from "./router";
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import pubic from '@/utils/pubic.js'
Vue.prototype.$pubic = pubic;
import {
  subscribe
} from './utils/mqtt.js'
var client;
if (!client) {
  var client = subscribe();
  client.on('connect', (err) => {
    console.log('连接成功!')
  }).on('reconnect', (err) => {
    console.log('正在重连...')
  }).on('end', (err) => {
    console.log('连接断开!')
  }).on('error', (err) => {
    console.log('客户端无法连接!')
  }).on('close', (err) => {
    console.log('close啦')
  })
}
client.on('message', (topic, message) => {
  pubic.mqtt(topic, message)
  console.log('接收推送信息')
})
Vue.prototype.$client = client;

Vue.config.productionTip = false
Vue.use(ElementUI);
new Vue({
  router,
  render: h => h(App),
}).$mount('#app')
